#include "paramhandler.hpp"
#include "presentation_swf.hpp"
//#include "presentation_png.hpp"
#include "presentation_pdf.hpp"

int main(int argc, char* argv[]) {
	int exitcode=EXIT_SUCCESS;
	string compile_slide("all");
	string input_file("");
	bool makepdf=false;
	
	try {
		param_handler p(argc,argv);
		p.shift();

		if(p.exist("--slide")) {
			compile_slide=p.string_value("--slide");
			p.remove_pair("--slide");
		} else if(p.exist("-s")) {
			compile_slide=p.string_value("-s");
			p.remove_pair("-s");
		}
		
		if(p.exist("--pdf")) {
			makepdf=true;
			p.remove("--pdf");
		}

		input_file=p[0];
		
		if(input_file=="") throw "Please give the file to parse in the parameter";
		cerr << "compiling file: " << input_file << "\n";
		
		if(makepdf) {
			presentation_pdf s(input_file);
			s.compile(compile_slide);
		} else {
			presentation_swf s(input_file);
			s.compile(compile_slide);
		}

	} catch(const char* msg) {
		cerr << msg << "\n";
		exitcode=EXIT_FAILURE;
	}
	return 0;
}
